package com.zzxx.mapper;

import com.zzxx.entity.Rule;
import com.zzxx.entity.RuleExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface RuleMapper extends RuleMapperEx {
    @SelectProvider(type=RuleSqlProvider.class, method="countByExample")
    long countByExample(RuleExample example);

    @DeleteProvider(type=RuleSqlProvider.class, method="deleteByExample")
    int deleteByExample(RuleExample example);

    @Delete({
        "delete from rule",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    @Insert({
        "insert into rule (id, targetType, ",
        "targetId, beforeDay, ",
        "weekendCanBook, holidayCanBook, ",
        "startTime, endTime, ",
        "ticketNum)",
        "values (#{id,jdbcType=VARCHAR}, #{targettype,jdbcType=INTEGER}, ",
        "#{targetid,jdbcType=VARCHAR}, #{beforeday,jdbcType=INTEGER}, ",
        "#{weekendcanbook,jdbcType=BIT}, #{holidaycanbook,jdbcType=BIT}, ",
        "#{starttime,jdbcType=TIMESTAMP}, #{endtime,jdbcType=TIMESTAMP}, ",
        "#{ticketnum,jdbcType=INTEGER})"
    })
    int insert(Rule row);

    @InsertProvider(type=RuleSqlProvider.class, method="insertSelective")
    int insertSelective(Rule row);

    @SelectProvider(type=RuleSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="targetType", property="targettype", jdbcType=JdbcType.INTEGER),
        @Result(column="targetId", property="targetid", jdbcType=JdbcType.VARCHAR),
        @Result(column="beforeDay", property="beforeday", jdbcType=JdbcType.INTEGER),
        @Result(column="weekendCanBook", property="weekendcanbook", jdbcType=JdbcType.BIT),
        @Result(column="holidayCanBook", property="holidaycanbook", jdbcType=JdbcType.BIT),
        @Result(column="startTime", property="starttime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="endTime", property="endtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="ticketNum", property="ticketnum", jdbcType=JdbcType.INTEGER)
    })
    List<Rule> selectByExample(RuleExample example);

    @Select({
        "select",
        "id, targetType, targetId, beforeDay, weekendCanBook, holidayCanBook, startTime, ",
        "endTime, ticketNum",
        "from rule",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="targetType", property="targettype", jdbcType=JdbcType.INTEGER),
        @Result(column="targetId", property="targetid", jdbcType=JdbcType.VARCHAR),
        @Result(column="beforeDay", property="beforeday", jdbcType=JdbcType.INTEGER),
        @Result(column="weekendCanBook", property="weekendcanbook", jdbcType=JdbcType.BIT),
        @Result(column="holidayCanBook", property="holidaycanbook", jdbcType=JdbcType.BIT),
        @Result(column="startTime", property="starttime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="endTime", property="endtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="ticketNum", property="ticketnum", jdbcType=JdbcType.INTEGER)
    })
    Rule selectByPrimaryKey(String id);

    @UpdateProvider(type=RuleSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("row") Rule row, @Param("example") RuleExample example);

    @UpdateProvider(type=RuleSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("row") Rule row, @Param("example") RuleExample example);

    @UpdateProvider(type=RuleSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Rule row);

    @Update({
        "update rule",
        "set targetType = #{targettype,jdbcType=INTEGER},",
          "targetId = #{targetid,jdbcType=VARCHAR},",
          "beforeDay = #{beforeday,jdbcType=INTEGER},",
          "weekendCanBook = #{weekendcanbook,jdbcType=BIT},",
          "holidayCanBook = #{holidaycanbook,jdbcType=BIT},",
          "startTime = #{starttime,jdbcType=TIMESTAMP},",
          "endTime = #{endtime,jdbcType=TIMESTAMP},",
          "ticketNum = #{ticketnum,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Rule row);
}